package com.xbao.dao;

import com.xbao.model.SpreadTemplate;
import com.xbao.model.SpreadTemplateExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface SpreadTemplateMapper {
    @SelectProvider(type=SpreadTemplateSqlProvider.class, method="countByExample")
    int countByExample(SpreadTemplateExample example);

    @DeleteProvider(type=SpreadTemplateSqlProvider.class, method="deleteByExample")
    int deleteByExample(SpreadTemplateExample example);

    @Delete({
        "delete from spread_template",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into spread_template (title, createtime, ",
        "updatetime, path, ",
        "type, cols)",
        "values (#{title,jdbcType=VARCHAR}, #{createtime,jdbcType=BIGINT}, ",
        "#{updatetime,jdbcType=BIGINT}, #{path,jdbcType=VARCHAR}, ",
        "#{type,jdbcType=INTEGER}, #{cols,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(SpreadTemplate record);

    @InsertProvider(type=SpreadTemplateSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(SpreadTemplate record);

    @SelectProvider(type=SpreadTemplateSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="cols", property="cols", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<SpreadTemplate> selectByExampleWithBLOBs(SpreadTemplateExample example);

    @SelectProvider(type=SpreadTemplateSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER)
    })
    List<SpreadTemplate> selectByExample(SpreadTemplateExample example);

    @Select({
        "select",
        "id, title, createtime, updatetime, path, type, cols",
        "from spread_template",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="cols", property="cols", jdbcType=JdbcType.LONGVARCHAR)
    })
    SpreadTemplate selectByPrimaryKey(Long id);

    @UpdateProvider(type=SpreadTemplateSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SpreadTemplate record, @Param("example") SpreadTemplateExample example);

    @UpdateProvider(type=SpreadTemplateSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") SpreadTemplate record, @Param("example") SpreadTemplateExample example);

    @UpdateProvider(type=SpreadTemplateSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SpreadTemplate record, @Param("example") SpreadTemplateExample example);

    @UpdateProvider(type=SpreadTemplateSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SpreadTemplate record);

    @Update({
        "update spread_template",
        "set title = #{title,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=BIGINT},",
          "updatetime = #{updatetime,jdbcType=BIGINT},",
          "path = #{path,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=INTEGER},",
          "cols = #{cols,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(SpreadTemplate record);

    @Update({
        "update spread_template",
        "set title = #{title,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=BIGINT},",
          "updatetime = #{updatetime,jdbcType=BIGINT},",
          "path = #{path,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(SpreadTemplate record);
}